import { Injectable, Logger } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { Repository } from 'typeorm';
import { ConfigService } from '@nestjs/config';
import { BaseService } from '@wwjCommon/base/base.service';
import { CacheService } from '@wwjCommon/cache/cache.service';
import { LoggingService } from '@wwjCommon/logging/logging.service';
import { UploadService } from '@wwjVendor/upload/upload.service';
import { PayService } from '@wwjVendor/pay/pay.service';
import { SmsService } from '@wwjVendor/sms/sms.service';
import { NoticeService } from '@wwjVendor/notice/notice.service';

@Injectable()
export class CoreDiyService extends BaseService<any> {
  private readonly logger = new Logger(CoreDiyService.name);

  constructor(
    @InjectRepository(Object)
    protected readonly repository: Repository<any>,
    private readonly cacheService: CacheService,
    private readonly configService: ConfigService,
    private readonly loggingService: LoggingService,
    private readonly uploadService: UploadService,
    private readonly payService: PayService,
    private readonly smsService: SmsService,
    private readonly noticeService: NoticeService,
  ) {
    super(repository);
  }

  /**
   * initDefaultDiyTheme
   * 对应 PHP: CoreDiyService_core::initDefaultDiyTheme()
   * 逻辑类型: undefined - undefined
   */
  async initDefaultDiyTheme(site_id: any) {
    // 基于PHP真实逻辑: initDefaultDiyTheme
    // PHP原文: $site_addon = ( new CoreSiteService() )->getSiteCache($site_id);         $system_theme = array_values(array_filter(event('ThemeColor', [ 'key' => 'app...
const site_addon = ( this.coreSiteService ).getSiteCache(site_id);
        const system_theme = array_values(array_filter(event('ThemeColor', [ key: 'app' ))))[ 0 ] || [];
        foreach (system_theme[ 'theme_color' ) as k => v) {
            data[] = [
                type: 'app',
                addon: 'app',
                site_id: site_id,
                title: v[ 'title' ],
                theme: v[ 'theme' ],
                default_theme: v[ 'theme' ],
                theme_type: 'default',
                is_selected: k == 0 ? 1 : 0,
                create_time: time(),
            ];
  }
}
